import React from 'react';
import {WeaSearchGroup, WeaFormItem, WeaCheckbox} from 'ecCom';
import {WeaLocaleProvider} from 'ecCom';
const getLabel = WeaLocaleProvider.getLabel;
import EType from './base/EType';
import ETitle from './base/ETitle';
import EShowNum from './base/EShowNum';
import ELinkMode from './base/ELinkMode';
import EScrollDirection from './base/EScrollDirection';
import './Style_FormMode.css';
// 建模查询中心
export default class Content_FormModeCustomSearch extends React.Component {
    state = {
        eIsShowTitle: this.props.eIsShowTitle,
        weaCubeLoaded: false,
        cubeQueryCenterStore:undefined,
    };

    componentWillMount() {
        // 异步加载表单建模模块静态资源
        eventRegister.loadModule('b_cube', () => {
            setTimeout(() => {const cubeQueryCenterStore=new window.weaCubeEngine.com.CubeQueryCenterStore();this.setState({weaCubeLoaded: true,cubeQueryCenterStore:cubeQueryCenterStore})}, 100);
        }, () => {
        });
    }

    render() {
        const {eIsShowTitle, weaCubeLoaded,cubeQueryCenterStore} = this.state;
        return (
            <div>
                <WeaSearchGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaSearchGroup@6zbw1k`} title={getLabel(81711, '基本信息')} needTigger={true} showGroup={true}>
                    <EType ecId={`${this && this.props && this.props.ecId || ''}_EType@tw1fto`} ref="eType" value={this.props.eBaseName}/>
                    {this.props.eShareLevel == '2' ? <ETitle ecId={`${this && this.props && this.props.ecId || ''}_ETitle@g2ojmw`} ref="eTitle" eid={this.props.eid} value={this.props.eTitle} {...this.props}/> : ''}
                    {this.props.eShareLevel == '2' ? <EShowNum ecId={`${this && this.props && this.props.ecId || ''}_EShowNum@0z38rd`} ref="eShowNum" value={this.props.eShowNum}/> : ''}
                    {this.props.eShareLevel == '2' ? <ELinkMode ecId={`${this && this.props && this.props.ecId || ''}_ELinkMode@rqqw24`} ref="eLinkMode" options={this.props.eLinkMode.options} value={(this.props.eLinkMode.selected == '-1' ? '2' : this.props.eLinkMode.selected) || '2'}/> : ''}
                    {
                        this.props.eShareLevel == '2' ? (
                                <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@1izo1g`} label={getLabel(84582,'是否显示表头') } className='portal-FormModeCustomSearch-perpage-label' style={{marginTop:'5px'}} labelCol={{span: 6}} wrapperCol={{span: 16}}>
                                    <div className="portal-FormModeCustomSearch-perpage">
                                        <WeaCheckbox ecId={`${this && this.props && this.props.ecId || ''}_WeaCheckbox@uacihe`} value={eIsShowTitle} onChange={(value) => this.setState({eIsShowTitle: value == '1'})}/>
                                    </div>
                                </WeaFormItem>
                            ) : ''
                    }
                    {this.props.eShareLevel == '2' ? <EScrollDirection ecId={`${this && this.props && this.props.ecId || ''}_EScrollDirection@vpjh86`} ref="eScrollDirection" options={this.props.eScrollDirection.options} value={this.props.eScrollDirection.selected}/> : ''}
                    {
                        this.props.eShareLevel == '2' ? (
                                <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@0auu9u`}  wrapperCol={{span: 22}}>
                                    {weaCubeLoaded && window.weaCubeEngine && window.weaCubeEngine.com ? <window.weaCubeEngine.com.CubeQueryCenterSet ecId={`${this && this.props && this.props.ecId || ''}_CubeQueryCenterSet@4hxgw3`} 
                                    CubeQueryCenterStore={cubeQueryCenterStore} 
                                    isCustom={true} eid={this.props.eid} hpid={this.props.hpid}
                                    /> 
                                    : <div></div>}
                                </WeaFormItem>
                            ) : ''
                    }
                </WeaSearchGroup>
            </div>
        );
    }

    getSaveValues() {
        return {
            eContentTitle: this.refs['eTitle'] ? this.refs['eTitle'].getSaveValues() : this.props.eTitle,
            eContentShowNum: this.refs['eShowNum'].getSaveValues(),
            eContentLinkMode: this.refs['eLinkMode'].getSaveValues(),
            eContentIsShowTitle: this.state.eIsShowTitle,
            eContentTabWidth: {tabwidth: this.props.etabwidth, methodvalue: this.props.methodvalue},
            eContentIsAlwaysShow: this.props.isAlwaysShow,
            eContenteTabStyle: {tabstyle: this.props.tabstyle, tabvalue: this.props.tabvalue, tabname: this.props.tabname},
            eContentScrollDirection: this.refs['eScrollDirection'] ? this.refs['eScrollDirection'].getSaveValues() : this.props.eScrollDirection.selected,
        };
    }
}